package week9;

import java.io.PrintStream;
import java.util.Random;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
import javax.microedition.rms.RecordStoreFullException;
import javax.microedition.rms.RecordStoreNotFoundException;

public class randomInfo extends MIDlet
{
  RMSAccount rmsa = new RMSAccount();
  RMSOperate rmso = new RMSOperate();
  String ss = "";
  String ss1 = "";
  private RecordStore rs_index = null;

  public randomInfo()
  {
    try
    {
      RecordStore.deleteRecordStore("phoneIndex2");
      System.out.println("cccd");
    }
    catch (RecordStoreFullException localRecordStoreFullException)
    {
      System.out.println("d");
    }
    catch (RecordStoreNotFoundException localRecordStoreNotFoundException1)
    {
      System.out.println("e");
    }
    catch (RecordStoreException localRecordStoreException1)
    {
      System.out.println("f");
    }
    try
    {
      RecordStore.deleteRecordStore("phoneAccount");
      System.out.println("ccddeee");
    }
    catch (RecordStoreNotFoundException localRecordStoreNotFoundException2)
    {
    }
    catch (RecordStoreException localRecordStoreException2)
    {
    }
    randomFun();
  }

  private void randomFun()
  {
    try
    {
    	int i,j,k,l;
      this.rs_index = RecordStore.openRecordStore("phoneIndex2", true);
      Random localRandom = new Random();
      for (i = 0; i < 10; ++i)
      {
        j = localRandom.nextInt();
        j = (j < 0) ? -j % 6 : j % 6;
        j += 6;
        this.ss = "";
        for (k = 0; k < j; ++k)
        {
          int i1;
          l = localRandom.nextInt();
          if (1 == ((l < 0) ? -l % 2 : l % 2))
          {
            i1 = localRandom.nextInt();
            i1 = (i1 < 0) ? -i1 % 26 : i1 % 26;
            this.ss += (char)(i1 + 65);
          }
          else
          {
            i1 = localRandom.nextInt();
            i1 = (i1 < 0) ? -i1 % 26 : i1 % 26;
            this.ss += (char)(i1 + 97);
          }
        }
        k = localRandom.nextInt();
        k = (k < 0) ? -k % 7 : k % 7;
        switch (k)
        {
        case 0:
          this.ss1 = this.ss + "@163.com";
          break;
        case 1:
          this.ss1 = this.ss + "@126.com";
          break;
        case 2:
          this.ss1 = this.ss + "@qq.com";
          break;
        case 3:
          this.ss1 = this.ss + "@Sina.com";
          break;
        case 4:
          this.ss1 = this.ss + "@Yahoo.com";
          break;
        case 5:
          this.ss1 = this.ss + "@Sohu.com";
          break;
        case 6:
          this.ss1 = this.ss + "@21.cn";
        }
        System.out.println(this.ss1);
        Account localAccount = new Account("13878955771", this.ss1);
        l = this.rmsa.addAccount(localAccount);
        System.out.println(l);
        Index localIndex = new Index(this.ss, l);
        this.rmso.addIndex(localIndex);
      }
      this.rs_index.closeRecordStore();
    }
    catch (RecordStoreFullException localRecordStoreFullException)
    {
      localRecordStoreFullException.printStackTrace();
    }
    catch (RecordStoreNotFoundException localRecordStoreNotFoundException)
    {
      localRecordStoreNotFoundException.printStackTrace();
    }
    catch (RecordStoreException localRecordStoreException)
    {
      localRecordStoreException.printStackTrace();
    }
  }

  protected void destroyApp(boolean paramBoolean)
    throws MIDletStateChangeException
  {
  }

  protected void pauseApp()
  {
  }

  protected void startApp()
    throws MIDletStateChangeException
  {
  }
}